import Vue from 'vue'
import Router from 'vue-router'
import iView from 'iview';
import Login from '@/views/Login'
import Main from '@/views/Main'
import Orders from '@/views/orders/Orders'
import OrderList from '@/views/orders/OrderList'

import OrderDetail from '@/views/orders/OrderDetail'
import OrderDetailU from '@/views/orders/OrderDetailU'

import AuditList from '@/views/audit/AuditList'
import AuditDetail from '@/views/audit/AuditDetail'

import UserIndex from '@/views/user/UserIndex'
import ReportIndex from '@/views/report/ReportIndex'




Vue.use(Router)


const router = new Router({
  routes: [
    {
      path: '/login',
      component: Login
    },
    {
      path: '/',
      name: 'Main',
      component: Main,
      description: "首页"
    },
    {
      path: '/orders',
      component: Main,
      children: [
        {
          path: '',
          name: 'Orders',
          component: Orders,
          children: [
            {
              path: 'orderList/:step',
              name: 'OrderList',
              component: OrderList,
            },
            {
              path: 'orderDetailU/:order_code',
              name: 'OrderDetailU',
              component: OrderDetailU,
            },
            {
              path: 'orderDetail/:order_code/:step',
              name: 'OrderDetail',
              component: OrderDetail,
            },
           
          ]
        },
       
      ]
    },
    {
      path: '/audit',
      component: Main,
      children: [
        {
          path: '',
          name: 'AuditList',
          component: AuditList,        
        },
        {
          path: 'detail',
          name: 'AuditDetail',
          component: AuditDetail,        
        },
        
      ]
    },
    {
      path: '/user',
      component: Main,
      children: [
        {
          path: '',
          name: 'UserIndex',
          component: UserIndex,        
        },     
      ]
    },
    {
      path: '/report',
      component: Main,
      children: [
        {
          path: '',
          name: 'ReportIndex',
          component: ReportIndex,        
        },     
      ]
    },
    { path: '*', redirect: '/' }
  ]
})

router.beforeEach((to, from, next) => {
  iView.LoadingBar.start();
  // console.log(to)
  next();
});

router.afterEach(() => {
  iView.LoadingBar.finish();
  window.scrollTo(0, 0);
});
export default router
